package com.zhiyou100.service.imp;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zhiyou100.IService.IserviceAP;
import com.zhiyou100.entity.adminP.TbAdmin;
import com.zhiyou100.entity.adminP.TbAdminExample;
import com.zhiyou100.entity.adminP.TbAdminExample.Criteria;
import com.zhiyou100.mapper.adminP.TbAdminMapper;

@Service
public class ServiceAPImp implements IserviceAP{

	@Resource
	private TbAdminMapper mapper;

	public List<TbAdmin> select(TbAdmin admin) {
		TbAdminExample example = new TbAdminExample();
		Criteria criteria = example.createCriteria();
		if (admin.getAdminName()!=null&&!admin.getAdminName().trim().isEmpty()) {
			criteria.andAdminNameEqualTo(admin.getAdminName());
		}
		if (admin.getAdminPowerId()!=null) {
			criteria.andAdminPowerIdEqualTo(admin.getAdminPowerId());
		}
		return mapper.selectByExample(example);
	}

	public boolean update(TbAdmin admin) {
		int num = mapper.updateByPrimaryKeySelective(admin);
		return num>0?true:false;
	}

	public boolean del(TbAdmin admin) {
		int num = mapper.deleteByPrimaryKey(admin.getAdminId());
		return num>0?true:false;
	}
}
